#include <iostream>
#include <QString>
using namespace std;
#include "User.h"


User::User(const int& id, const QString& name, const QString& password, PB_t permissionBits, const QString& roleDescription) :
    id(id), name(name), password(password), permissionBits(permissionBits), roleDescription(roleDescription) {
}

User::User( const QString &name, const QString &password, PB_t permissionBits, Role role, const QString &roleDescription):
    name(name), password(password), permissionBits(permissionBits),role(role), roleDescription(roleDescription) {
}
User::~User() {}

int User::getId() const { return this->id; }
QString User::getName()const { return this->name; }
QString User::getPassword()const { return this->password; }
PB_t User::getPermissionBits()const { return this->permissionBits; }
Role User::getRole()const { return this->role; }
QString User::getRoleDescription()const { return this->roleDescription; }

void User::setPermissionBits(PB_t permissionBits) { this->permissionBits = permissionBits; }
void User::setRole(Role role) { this->role = role; }

bool User::check_permission(UPBits pb)
{
    if ((this->permissionBits & static_cast<PB_t>(pb)) == static_cast<PB_t>(pb))
        return true;
    return false;
}

